var o = require("../z-paging-utils.js"), t = {
    props: {
        autoShowBackToTop: {
            type: Boolean,
            default: o.u.gc("autoShowBackToTop", !1)
        },
        backToTopThreshold: {
            type: [ Number, String ],
            default: o.u.gc("backToTopThreshold", "400rpx")
        },
        backToTopImg: {
            type: String,
            default: o.u.gc("backToTopImg", "")
        },
        backToTopWithAnimate: {
            type: Boolean,
            default: o.u.gc("backToTopWithAnimate", !0)
        },
        backToTopBottom: {
            type: [ Number, String ],
            default: o.u.gc("backToTopBottom", "160rpx")
        },
        backToTopStyle: {
            type: Object,
            default: function() {
                return o.u.gc("backToTopStyle", {});
            }
        },
        enableBackToTop: {
            type: Boolean,
            default: o.u.gc("enableBackToTop", !0)
        }
    },
    data: function() {
        return {
            backToTopClass: "zp-back-to-top zp-back-to-top-hide",
            lastBackToTopShowTime: 0,
            showBackToTopClass: !1
        };
    },
    computed: {
        finalEnableBackToTop: function() {
            return !this.usePageScroll && this.enableBackToTop;
        },
        finalBackToTopThreshold: function() {
            return o.u.convertToPx(this.backToTopThreshold);
        },
        finalBackToTopStyle: function() {
            var t = this.backToTopStyle;
            return t.bottom || (t.bottom = this.windowBottom + o.u.convertToPx(this.backToTopBottom) + "px"), 
            t.position || (t.position = this.usePageScroll ? "fixed" : "absolute"), t;
        }
    },
    methods: {
        _backToTopClick: function() {
            var o = this, t = !1;
            this.$emit("backToTopClick", function(T) {
                (void 0 === T || !0 === T) && o._handleToTop(), t = !0;
            }), this.$nextTick(function() {
                !t && o._handleToTop();
            });
        },
        _handleToTop: function() {
            !this.backToTopWithAnimate && this._checkShouldShowBackToTop(0), this.scrollToTop(this.backToTopWithAnimate);
        },
        _checkShouldShowBackToTop: function(t) {
            var T = this;
            this.autoShowBackToTop ? t > this.finalBackToTopThreshold ? this.showBackToTopClass || (this.showBackToTopClass = !0, 
            this.lastBackToTopShowTime = new Date().getTime(), o.u.delay(function() {
                T.backToTopClass = "zp-back-to-top zp-back-to-top-show";
            }, 300)) : this.showBackToTopClass && (this.backToTopClass = "zp-back-to-top zp-back-to-top-hide", 
            o.u.delay(function() {
                T.showBackToTopClass = !1;
            }, new Date().getTime() - this.lastBackToTopShowTime < 500 ? 0 : 300)) : this.showBackToTopClass = !1;
        }
    }
};

exports.backToTopModule = t;